/** 
 * File-Name:ArticleDao.java
 *
 * Created on 2011-6-2 下午03:45:50
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package site.dao;

import java.sql.Connection;
import java.sql.SQLException;

import neoutil.CommonDao;
import site.entity.Paper;

/**
 * Description:
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-6-2 下午03:45:50
 */
public class PaperDao extends CommonDao<Paper, Long>{
	
	public PaperDao(Connection connection) {
		super(Paper.class, connection);
	}

	public void save(Paper paper) throws SQLException {
		Object[] params = { paper.getUuid(),paper.getTitle(),paper.getDescription(),
				paper.getFilePath(),paper.getAuthorName(),paper.getSource(),paper.getType(),paper.getCid(),paper.getPublishDate()};
		execute(SQLString.SQL_PAPER_INSERT, params);
	}

	public void update(Paper paper) throws SQLException {
		Object[] params = { paper.getUuid(),paper.getTitle(),paper.getDescription(),
				paper.getFilePath(),paper.getAuthorName(),paper.getSource(),paper.getType(),paper.getCid(),paper.getPublishDate(), paper.getId() };
		execute(SQLString.SQL_PAPER_UPDATE, params);
	}
	
	public void delete(Paper paper) throws SQLException {
		Object[] params = {paper.getId()};
		execute(SQLString.SQL_PAPER_DELETE, params);
	}
}
